home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / RCS_56.ARJ / RCSBASE.H < prev    next >
C/C++ Source or Header  |  1992-02-11  |  22KB  |  678 lines

  1.  
  2. /*
  3.  *                     RCS common definitions and data structures
  4.  */
  5. #define RCSBASE "$Id: rcsbase.h,v 5.11 1991/10/07 17:32:46 eggert Exp $"
  6.  
  7. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  8.    Copyright 1990, 1991 by Paul Eggert
  9.    Distributed under license by the Free Software Foundation, Inc.
  10.  
  11. This file is part of RCS.
  12.  
  13. RCS is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2, or (at your option)
  16. any later version.
  17.  
  18. RCS is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with RCS; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. Report problems and direct all questions to:
  28.  
  29.     rcs-bugs@cs.purdue.edu
  30.  
  31. */
  32.  
  33.  
  34.  
  35. /*****************************************************************************
  36.  * INSTRUCTIONS:
  37.  * =============
  38.  * See the Makefile for how to define C preprocessor symbols.
  39.  * If you need to change the comment leaders, update the table comtable[]
  40.  * in rcsfnms.c. (This can wait until you know what a comment leader is.)
  41.  *****************************************************************************
  42.  */
  43.  
  44.  
  45. /* $Log: rcsbase.h,v $
  46.  * Revision 5.11  1991/10/07  17:32:46  eggert
  47.  * Support piece tables even if !has_mmap.
  48.  *
  49.  * Revision 5.10  1991/09/24  00:28:39  eggert
  50.  * Remove unexported functions.
  51.  *
  52.  * Revision 5.9  1991/08/19  03:13:55  eggert
  53.  * Add piece tables and other tuneups, and NFS workarounds.
  54.  *
  55.  * Revision 5.8  1991/04/21  11:58:20  eggert
  56.  * Add -x, RCSINIT, MS-DOS support.
  57.  *
  58.  * Revision 5.7  1991/02/28  19:18:50  eggert
  59.  * Try setuid() if seteuid() doesn't work.
  60.  *
  61.  * Revision 5.6  1991/02/26  17:48:37  eggert
  62.  * Support new link behavior.  Move ANSI C / Posix declarations into conf.sh.
  63.  *
  64.  * Revision 5.5  1990/12/04  05:18:43  eggert
  65.  * Use -I for prompts and -q for diagnostics.
  66.  *
  67.  * Revision 5.4  1990/11/01  05:03:35  eggert
  68.  * Don't assume that builtins are functions; they may be macros.
  69.  * Permit arbitrary data in logs.
  70.  *
  71.  * Revision 5.3  1990/09/26  23:36:58  eggert
  72.  * Port wait() to non-Posix ANSI C hosts.
  73.  *
  74.  * Revision 5.2  1990/09/04  08:02:20  eggert
  75.  * Don't redefine NAME_MAX, PATH_MAX.
  76.  * Improve incomplete line handling.  Standardize yes-or-no procedure.
  77.  *
  78.  * Revision 5.1  1990/08/29  07:13:53  eggert
  79.  * Add -kkvl.  Fix type typos exposed by porting.  Clean old log messages too.
  80.  *
  81.  * Revision 5.0  1990/08/22  08:12:44  eggert
  82.  * Adjust ANSI C / Posix support.  Add -k, -V, setuid.  Don't call access().
  83.  * Remove compile-time limits; use malloc instead.
  84.  * Ansify and Posixate.  Add support for ISO 8859.
  85.  * Remove snoop and v2 support.
  86.  *
  87.  * Revision 4.9  89/05/01  15:17:14  narten
  88.  * botched previous USG fix 
  89.  * 
  90.  * Revision 4.8  89/05/01  14:53:05  narten
  91.  * changed #include <strings.h> -> string.h for USG systems.
  92.  * 
  93.  * Revision 4.7  88/11/08  15:58:45  narten
  94.  * removed defs for functions loaded from libraries
  95.  * 
  96.  * Revision 4.6  88/08/09  19:12:36  eggert
  97.  * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
  98.  * 
  99.  * Revision 4.5  87/12/18  17:06:41  narten
  100.  * made removed BSD ifdef, now uses V4_2BSD
  101.  * 
  102.  * Revision 4.4  87/10/18  10:29:49  narten
  103.  * Updating version numbers
  104.  * Changes relative to 1.1 are actually relative to 4.2
  105.  * 
  106.  * Revision 1.3  87/09/24  14:02:25  narten
  107.  * changes for lint
  108.  * 
  109.  * Revision 1.2  87/03/27  14:22:02  jenkins
  110.  * Port to suns
  111.  * 
  112.  * Revision 4.2  83/12/20  16:04:20  wft
  113.  * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
  114.  * moved setting of STRICT_LOCKING to Makefile.
  115.  * changed DOLLAR to UNKN (conflict with KDELIM).
  116.  * 
  117.  * Revision 4.1  83/05/04  09:12:41  wft
  118.  * Added markers Id and RCSfile.
  119.  * Added Dbranch for default branches.
  120.  * 
  121.  * Revision 3.6.1.1  83/12/02  21:56:22  wft
  122.  * Increased logsize, added macro SMALLOG.
  123.  * 
  124.  * Revision 3.6  83/01/15  16:43:28  wft
  125.  * 4.2 prerelease
  126.  * 
  127.  * Revision 3.6  83/01/15  16:43:28  wft
  128.  * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
  129.  * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
  130.  * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
  131.  * Added macro DELETE to mark deleted deltas.
  132.  *
  133.  * Revision 3.5  82/12/10  12:16:56  wft
  134.  * Added two forms of DATEFORM, one using %02d, the other %.2d.
  135.  *
  136.  * Revision 3.4  82/12/04  20:01:25  wft
  137.  * added LOCKER, Locker, and USG (redefinition of rindex).
  138.  *
  139.  * Revision 3.3  82/12/03  12:22:04  wft
  140.  * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
  141.  * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
  142.  * using NCPPN. Changed putc() to abort on write error.
  143.  *
  144.  * Revision 3.2  82/10/18  15:03:52  wft
  145.  * added macro STRICT_LOCKING, removed RCSUMASK.
  146.  * renamed JOINFILE[1,2] to JOINFIL[1,2].
  147.  *
  148.  * Revision 3.1  82/10/11  19:41:17  wft
  149.  * removed NBPW, NBPC, NCPW.
  150.  * added typdef int void to aid compiling
  151.  */
  152.  
  153.  
  154. #include "conf.h"
  155.  
  156.  
  157. #define EXIT_TROUBLE DIFF_TROUBLE
  158.  
  159. #ifdef PATH_MAX
  160. #    define SIZEABLE_PATH PATH_MAX /* size of a large path; not a hard limit */
  161. #else
  162. #    define SIZEABLE_PATH _POSIX_PATH_MAX
  163. #endif
  164.  
  165. /* for traditional C hosts with unusual size arguments */
  166. #define Fread(p,s,n,f)  fread(p, (freadarg_type)(s), (freadarg_type)(n), f)
  167. #define Fwrite(p,s,n,f)  fwrite(p, (freadarg_type)(s), (freadarg_type)(n), f)
  168.  
  169.  
  170. /*
  171.  * Parameters
  172.  */
  173.  
  174. /* backwards compatibility with old versions of RCS */
  175. #define VERSION_min 3        /* old output RCS format supported */
  176. #define VERSION_max 5        /* newest output RCS format supported */
  177. #ifndef VERSION_DEFAULT        /* default RCS output format */
  178. #    define VERSION_DEFAULT VERSION_max
  179. #endif
  180. #define VERSION(n) ((n) - VERSION_DEFAULT) /* internally, 0 is the default */
  181.  
  182. #ifndef STRICT_LOCKING
  183. #define STRICT_LOCKING 1
  184. #endif
  185.                   /* 0 sets the default locking to non-strict;  */
  186.                               /* used in experimental environments.         */
  187.                               /* 1 sets the default locking to strict;      */
  188.                               /* used in production environments.           */
  189.  
  190. #define yearlength       16 /* (good through AD 9,999,999,999,999,999)    */
  191. #define datesize (yearlength+16) /* size of output of DATEFORM            */
  192. #define joinlength         20 /* number of joined revisions permitted       */
  193. #define RCSTMPPREFIX '_' /* prefix for temp files in working dir  */
  194. #define KDELIM            '$' /* delimiter for keywords                     */
  195. #define VDELIM            ':' /* separates keywords from values             */
  196. #define DEFAULTSTATE    "Exp" /* default state of revisions                 */
  197.  
  198.  
  199.  
  200. #define true     1
  201. #define false    0
  202. #define nil      0
  203.  
  204.  
  205. /*
  206.  * RILE - readonly file
  207.  * declarecache; - declares local cache for RILE variable(s)
  208.  * setupcache - sets up the local RILE cache, but does not initialize it
  209.  * cache, uncache - caches and uncaches the local RILE;
  210.  *    (uncache,cache) is needed around functions that advance the RILE pointer
  211.  * Igeteof(f,c,s) - get a char c from f, executing statement s at EOF
  212.  * cachegeteof(c,s) - Igeteof applied to the local RILE
  213.  * Iget(f,c) - like Igeteof, except EOF is an error
  214.  * cacheget(c) - Iget applied to the local RILE
  215.  * Ifileno, Irewind, Iseek, Itell - analogs to stdio routines
  216.  */
  217.  
  218. #if large_memory
  219.     typedef unsigned char const *Iptr_type;
  220.     typedef struct {
  221.         Iptr_type ptr, lim;
  222.         unsigned char *base; /* for lint, not Iptr_type even if has_mmap */
  223. #        if has_mmap
  224. #            define Ifileno(f) ((f)->fd)
  225.             int fd;
  226. #        else
  227. #            define Ifileno(f) fileno((f)->stream)
  228.             FILE *stream;
  229.             unsigned char *readlim;
  230. #        endif
  231.     } RILE;
  232. #    if has_mmap
  233. #        define declarecache register Iptr_type ptr, lim
  234. #        define setupcache(f) (lim = (f)->lim)
  235. #        define Igeteof(f,c,s) if ((f)->ptr==(f)->lim) s else (c)= *(f)->ptr++
  236. #        define cachegeteof(c,s) if (ptr==lim) s else (c)= *ptr++
  237. #    else
  238. #        define declarecache register Iptr_type ptr; register RILE *rRILE
  239. #        define setupcache(f) (rRILE = (f))
  240. #        define Igeteof(f,c,s) if ((f)->ptr==(f)->readlim && !Igetmore(f)) s else (c)= *(f)->ptr++
  241. #        define cachegeteof(c,s) if (ptr==rRILE->readlim && !Igetmore(rRILE)) s else (c)= *ptr++
  242. #    endif
  243. #    define uncache(f) ((f)->ptr = ptr)
  244. #    define cache(f) (ptr = (f)->ptr)
  245. #    define Iget(f,c) Igeteof(f,c,Ieof();)
  246. #    define cacheget(c) cachegeteof(c,Ieof();)
  247. #    define Itell(f) ((f)->ptr)
  248. #    define Iseek(f,p) ((f)->ptr = (p))
  249. #    define Irewind(f) Iseek(f, (f)->base)
  250. #    define cachetell() ptr
  251. #else
  252. #    define RILE FILE
  253. #    define declarecache register FILE *ptr
  254. #    define setupcache(f) (ptr = (f))
  255. #    define uncache(f)
  256. #    define cache(f)
  257. #    define Igeteof(f,c,s) if(((c)=getc(f))<0){testIerror(f);if(feof(f))s}else
  258. #    define cachegeteof(c,s) Igeteof(ptr,c,s)
  259. #    define Iget(f,c) if (((c)=getc(f))<0) testIeof(f); else
  260. #    define cacheget(c) Iget(ptr,c)
  261. #    define Ifileno(f) fileno(f)
  262. #endif
  263.  
  264. /* Print a char, but abort on write error.  */
  265. #define aputc(c,o) if (putc(c,o)<0) testOerror(o); else
  266.  
  267. /* Get a character from an RCS file, perhaps copying to a new RCS file.  */
  268. #define GETCeof(o,c,s) { cachegeteof(c,s); if (o) aputc(c,o); }
  269. #define GETC(o,c) { cacheget(c); if (o) aputc(c,o); }
  270.  
  271.  
  272. #define WORKMODE(RCSmode, writable) ((RCSmode)&~(S_IWUSR|S_IWGRP|S_IWOTH) | ((writable)?S_IWUSR:0))
  273. /* computes mode of working file: same as RCSmode, but write permission     */
  274. /* determined by writable */
  275.  
  276.  
  277. /* character classes and token codes */
  278. enum tokens {
  279. /* classes */    DELIM,    DIGIT,    IDCHAR,    NEWLN,    LETTER,    Letter,
  280.         PERIOD,    SBEGIN,    SPACE,    UNKN,
  281. /* tokens */    COLON,    ID,    NUM,    SEMI,    STRING
  282. };
  283.  
  284. #define SDELIM  '@'     /* the actual character is needed for string handling*/
  285. /* SDELIM must be consistent with ctab[], so that ctab[SDELIM]==SBEGIN.
  286.  * there should be no overlap among SDELIM, KDELIM, and VDELIM
  287.  */
  288.  
  289. #define isdigit(c) ((unsigned)((c)-'0') <= 9) /* faster than ctab[c]==DIGIT */
  290.  
  291.  
  292.  
  293.  
  294.  
  295. /***************************************
  296.  * Data structures for the symbol table
  297.  ***************************************/
  298.  
  299. /* Buffer of arbitrary data */
  300. struct buf {
  301.     char *string;
  302.     size_t size;
  303. };
  304. struct cbuf {
  305.     char const *string;
  306.     size_t size;
  307. };
  308.  
  309. /* Hash table entry */
  310. struct hshentry {
  311.     char const      * num;      /* pointer to revision number (ASCIZ) */
  312.     char const      * date;     /* pointer to date of checkin        */
  313.     char const      * author;   /* login of person checking in        */
  314.     char const      * lockedby; /* who locks the revision            */
  315.     char const      * state;    /* state of revision (Exp by default) */
  316.     struct cbuf        log;      /* log message requested at checkin   */
  317.         struct branchhead * branches; /* list of first revisions on branches*/
  318.     struct cbuf        ig;          /* ignored phrases of revision        */
  319.         struct hshentry   * next;     /* next revision on same branch       */
  320.     struct hshentry   * nexthsh;  /* next revision with same hash value */
  321.     unsigned long        insertlns;/* lines inserted (computed by rlog)  */
  322.     unsigned long        deletelns;/* lines deleted  (computed by rlog)  */
  323.     char            selector; /* true if selected, false if deleted */
  324. };
  325.  
  326. /* list of hash entries */
  327. struct hshentries {
  328.     struct hshentries *rest;
  329.     struct hshentry *first;
  330. };
  331.  
  332. /* list element for branch lists */
  333. struct branchhead {
  334.         struct hshentry   * hsh;
  335.         struct branchhead * nextbranch;
  336. };
  337.  
  338. /* accesslist element */
  339. struct access {
  340.     char const      * login;
  341.         struct access     * nextaccess;
  342. };
  343.  
  344. /* list element for locks  */
  345. struct lock {
  346.     char const      * login;
  347.         struct hshentry   * delta;
  348.         struct lock       * nextlock;
  349. };
  350.  
  351. /* list element for symbolic names */
  352. struct assoc {
  353.     char const      * symbol;
  354.     char const      * num;
  355.         struct assoc      * nextassoc;
  356. };
  357.  
  358.  
  359. #define mainArgs (argc,argv) int argc; char **argv;
  360.  
  361. #if lint
  362. #    define libId(name,rcsid)
  363. #    define mainProg(name,cmd,rcsid) int name mainArgs
  364. #else
  365. #    define libId(name,rcsid) char const name[] = rcsid;
  366. #    define mainProg(name,cmd,rcsid) char const copyright[] = "Copyright 1982,1988,1989 by Walter F. Tichy\nPurdue CS\nCopyright 1990,1991 by Paul Eggert", rcsbaseId[] = RCSBASE, cmdid[] = cmd; libId(name,rcsid) int main mainArgs
  367. #endif
  368.  
  369. /*
  370.  * Markers for keyword expansion (used in co and ident)
  371.  *    Every byte must have class LETTER or Letter.
  372.  */
  373. #define AUTHOR          "Author"
  374. #define DATE            "Date"
  375. #define HEADER          "Header"
  376. #define IDH             "Id"
  377. #define LOCKER          "Locker"
  378. #define LOG             "Log"
  379. #define RCSFILE         "RCSfile"
  380. #define REVISION        "Revision"
  381. #define SOURCE          "Source"
  382. #define STATE           "State"
  383. #define keylength 8 /* max length of any of the above keywords */
  384.  
  385. enum markers { Nomatch, Author, Date, Header, Id,
  386.            Locker, Log, RCSfile, Revision, Source, State };
  387.     /* This must be in the same order as rcskeys.c's Keyword[] array. */
  388.  
  389. #define DELNUMFORM      "\n\n%s\n%s\n"
  390. /* used by putdtext and scanlogtext */
  391.  
  392. #define EMPTYLOG "*** empty log message ***" /* used by ci and rlog */
  393.  
  394. /* main program */
  395. extern char const cmdid[];
  396. exiting void exiterr P((void));
  397.  
  398. /* maketime */
  399. int setfiledate P((char const*,char const[datesize]));
  400. void str2date P((char const*,char[datesize]));
  401. void time2date P((time_t,char[datesize]));
  402.  
  403. /* merge */
  404. int merge P((int,char const*const[2],char const*const[3]));
  405.  
  406. /* partime */
  407. int partime P((char const*,struct tm*,int*));
  408.  
  409. /* rcsedit */
  410. #define ciklogsize 23 /* sizeof("checked in with -k by ") */
  411. extern FILE *fcopy;
  412. extern char const *resultfile;
  413. extern char const ciklog[ciklogsize];
  414. extern int locker_expansion;
  415. extern struct buf dirtfname[];
  416. #define newRCSfilename (dirtfname[0].string)
  417. RILE *rcswriteopen P((struct buf*,struct stat*,int));
  418. char const *makedirtemp P((char const*,int));
  419. char const *getcaller P((void));
  420. int addlock P((struct hshentry*));
  421. int addsymbol P((char const*,char const*,int));
  422. int checkaccesslist P((void));
  423. int chnamemod P((FILE**,char const*,char const*,mode_t));
  424. int donerewrite P((int));
  425. int dorewrite P((int,int));
  426. int expandline P((RILE*,FILE*,struct hshentry const*,int,FILE*));
  427. int findlock P((int,struct hshentry**));
  428. void aflush P((FILE*));
  429. void copystring P((void));
  430. void dirtempunlink P((void));
  431. void enterstring P((void));
  432. void finishedit P((struct hshentry const*,FILE*,int));
  433. void keepdirtemp P((char const*));
  434. void openfcopy P((FILE*));
  435. void snapshotedit P((FILE*));
  436. void xpandstring P((struct hshentry const*));
  437. #if has_NFS || bad_unlink
  438.     int un_link P((char const*));
  439. #else
  440. #    define un_link(s) unlink(s)
  441. #endif
  442. #if large_memory
  443.     void edit_string P((void));
  444. #    define editstring(delta) edit_string()
  445. #else
  446.     void editstring P((struct hshentry const*));
  447. #endif
  448.  
  449. /* rcsfcmp */
  450. int rcsfcmp P((RILE*,struct stat const*,char const*,struct hshentry const*));
  451.  
  452. /* rcsfnms */
  453. #define bufautobegin(b) ((void) ((b)->string = 0, (b)->size = 0))
  454. extern FILE *workstdout;
  455. extern char *workfilename;
  456. extern char const *RCSfilename;
  457. extern char const *suffixes;
  458. extern struct stat RCSstat;
  459. RILE *rcsreadopen P((struct buf*,struct stat*,int));
  460. char *bufenlarge P((struct buf*,char const**));
  461. char const *basename P((char const*));
  462. char const *getfullRCSname P((void));
  463. char const *maketemp P((int));
  464. char const *rcssuffix P((char const*));
  465. int pairfilenames P((int,char**,RILE*(*)P((struct buf*,struct stat*,int)),int,int));
  466. size_t dirlen P((char const*));
  467. struct cbuf bufremember P((struct buf*,size_t));
  468. void bufalloc P((struct buf*,size_t));
  469. void bufautoend P((struct buf*));
  470. void bufrealloc P((struct buf*,size_t));
  471. void bufscat P((struct buf*,char const*));
  472. void bufscpy P((struct buf*,char const*));
  473. void tempunlink P((void));
  474.  
  475. /* rcsgen */
  476. extern int interactiveflag;
  477. extern struct buf curlogbuf;
  478. char const *buildrevision P((struct hshentries const*,struct hshentry*,FILE*,int));
  479. int getcstdin P((void));
  480. int ttystdin P((void));
  481. int yesorno P((int,char const*,...));
  482. struct cbuf cleanlogmsg P((char*,size_t));
  483. struct cbuf getsstdin P((char const*,char const*,char const*,struct buf*));
  484. void putdesc P((int,char*));
  485.  
  486. /* rcskeep */
  487. extern int prevkeys;
  488. extern struct buf prevauthor, prevdate, prevrev, prevstate;
  489. int getoldkeys P((RILE*));
  490.  
  491. /* rcskeys */
  492. extern char const *const Keyword[];
  493. enum markers trymatch P((char const*));
  494.  
  495. /* rcslex */
  496. extern FILE *foutptr;
  497. extern FILE *frewrite;
  498. extern RILE *finptr;
  499. extern char const *NextString;
  500. extern enum tokens nexttok;
  501. extern int hshenter;
  502. extern int nerror;
  503. extern int nextc;
  504. extern int quietflag;
  505. extern unsigned long rcsline;
  506. char const *getid P((void));
  507. exiting void efaterror P((char const*));
  508. exiting void enfaterror P((int,char const*));
  509. exiting void faterror P((char const*,...));
  510. exiting void fatserror P((char const*,...));
  511. exiting void Ieof P((void));
  512. exiting void Ierror P((void));
  513. exiting void Oerror P((void));
  514. char *checkid P((char*,int));
  515. int eoflex P((void));
  516. int getkeyopt P((char const*));
  517. int getlex P((enum tokens));
  518. struct cbuf getphrases P((char const*));
  519. struct cbuf savestring P((struct buf*));
  520. struct hshentry *getnum P((void));
  521. void Ifclose P((RILE*));
  522. void Izclose P((RILE**));
  523. void Lexinit P((void));
  524. void Ofclose P((FILE*));
  525. void Ozclose P((FILE**));
  526. void afputc P((int,FILE*));
  527. void aprintf P((FILE*,char const*,...));
  528. void aputs P((char const*,FILE*));
  529. void checksid P((char*));
  530. void diagnose P((char const*,...));
  531. void eerror P((char const*));
  532. void eflush P((void));
  533. void enerror P((int,char const*));
  534. void error P((char const*,...));
  535. void fvfprintf P((FILE*,char const*,va_list));
  536. void getkey P((char const*));
  537. void getkeystring P((char const*));
  538. void nextlex P((void));
  539. void oflush P((void));
  540. void printstring P((void));
  541. void readstring P((void));
  542. void redefined P((int));
  543. void testIerror P((FILE*));
  544. void testOerror P((FILE*));
  545. void warn P((char const*,...));
  546. void warnignore P((void));
  547. #if has_madvise && has_mmap && large_memory
  548.     void advise_access P((RILE*,int));
  549. #    define if_advise_access(p,f,advice) if (p) advise_access(f,advice)
  550. #else
  551. #    define advise_access(f,advice)
  552. #    define if_advise_access(p,f,advice)
  553. #endif
  554. #if has_mmap && large_memory
  555.     RILE *I_open P((char const*,struct stat*));
  556. #    define Iopen(f,m,s) I_open(f,s)
  557. #else
  558.     RILE *Iopen P((char const*,char const*,struct stat*));
  559. #endif
  560. #if !large_memory
  561.     void testIeof P((FILE*));
  562.     void Irewind P((RILE*));
  563. #endif
  564.  
  565. /* rcsmap */
  566. extern const enum tokens ctab[];
  567.  
  568. /* rcsrev */
  569. char *partialno P((struct buf*,char const*,unsigned));
  570. char const *tiprev P((void));
  571. int cmpnum P((char const*,char const*));
  572. int cmpnumfld P((char const*,char const*,unsigned));
  573. int compartial P((char const*,char const*,unsigned));
  574. int expandsym P((char const*,struct buf*));
  575. int fexpandsym P((char const*,struct buf*,RILE*));
  576. struct hshentry *genrevs P((char const*,char const*,char const*,char const*,struct hshentries**));
  577. unsigned countnumflds P((char const*));
  578. void getbranchno P((char const*,struct buf*));
  579.  
  580. /* rcssyn */
  581. /* These expand modes must agree with Expand_names[] in rcssyn.c.  */
  582. #define KEYVAL_EXPAND 0 /* -kkv `$Keyword: value $' */
  583. #define KEYVALLOCK_EXPAND 1 /* -kkvl `$Keyword: value locker $' */
  584. #define KEY_EXPAND 2 /* -kk `$Keyword$' */
  585. #define VAL_EXPAND 3 /* -kv `value' */
  586. #define OLD_EXPAND 4 /* -ko use old string, omitting expansion */
  587. struct diffcmd {
  588.     unsigned long
  589.         line1, /* number of first line */
  590.         nlines, /* number of lines affected */
  591.         adprev, /* previous 'a' line1+1 or 'd' line1 */
  592.         dafter; /* sum of previous 'd' line1 and previous 'd' nlines */
  593. };
  594. extern char const      * Dbranch;
  595. extern struct access   * AccessList;
  596. extern struct assoc    * Symbols;
  597. extern struct cbuf Comment;
  598. extern struct lock     * Locks;
  599. extern struct hshentry * Head;
  600. extern int         Expand;
  601. extern int               StrictLocks;
  602. extern unsigned TotalDeltas;
  603. extern char const *const expand_names[];
  604. extern char const Kdesc[];
  605. extern char const Klog[];
  606. extern char const Ktext[];
  607. int getdiffcmd P((RILE*,int,FILE*,struct diffcmd*));
  608. int putdftext P((char const*,struct cbuf,RILE*,FILE*,int));
  609. int putdtext P((char const*,struct cbuf,char const*,FILE*,int));
  610. int str2expmode P((char const*));
  611. void getadmin P((void));
  612. void getdesc P((int));
  613. void gettree P((void));
  614. void ignorephrase P((void));
  615. void initdiffcmd P((struct diffcmd*));
  616. void putadmin P((FILE*));
  617. void putstring P((FILE*,int,struct cbuf,int));
  618. void puttree P((struct hshentry const*,FILE*));
  619.  
  620. /* rcsutil */
  621. extern int RCSversion;
  622. char *cgetenv P((char const*));
  623. char *fstr_save P((char const*));
  624. char *str_save P((char const*));
  625. char const *date2str P((char const[datesize],char[datesize]));
  626. char const *getusername P((int));
  627. int getRCSINIT P((int,char**,char***));
  628. int run P((char const*,char const*,...));
  629. int runv P((char const**));
  630. malloc_type fremember P((malloc_type));
  631. malloc_type ftestalloc P((size_t));
  632. malloc_type testalloc P((size_t));
  633. malloc_type testrealloc P((malloc_type,size_t));
  634. #define ftalloc(T) ftnalloc(T,1)
  635. #define talloc(T) tnalloc(T,1)
  636. #if lint
  637.     extern malloc_type lintalloc;
  638. #    define ftnalloc(T,n) (lintalloc = ftestalloc(sizeof(T)*(n)), (T*)0)
  639. #    define tnalloc(T,n) (lintalloc = testalloc(sizeof(T)*(n)), (T*)0)
  640. #    define trealloc(T,p,n) (lintalloc = testrealloc((malloc_type)0, sizeof(T)*(n)), p)
  641. #    define tfree(p)
  642. #else
  643. #    define ftnalloc(T,n) ((T*) ftestalloc(sizeof(T)*(n)))
  644. #    define tnalloc(T,n) ((T*) testalloc(sizeof(T)*(n)))
  645. #    define trealloc(T,p,n) ((T*) testrealloc((malloc_type)(p), sizeof(T)*(n)))
  646. #    define tfree(p) free((malloc_type)(p))
  647. #endif
  648. void awrite P((char const*,size_t,FILE*));
  649. void fastcopy P((RILE*,FILE*));
  650. void ffree P((void));
  651. void ffree1 P((char const*));
  652. void setRCSversion P((char const*));
  653. #if has_signal
  654.     void catchints P((void));
  655.     void ignoreints P((void));
  656.     void restoreints P((void));
  657. #else
  658. #    define catchints()
  659. #    define ignoreints()
  660. #    define restoreints()
  661. #endif
  662. #if has_getuid
  663.     uid_t ruid P((void));
  664. #    define myself(u) ((u) == ruid())
  665. #else
  666. #    define myself(u) true
  667. #endif
  668. #if has_setuid
  669.     uid_t euid P((void));
  670.     void nosetid P((void));
  671.     void seteid P((void));
  672.     void setrid P((void));
  673. #else
  674. #    define nosetid()
  675. #    define seteid()
  676. #    define setrid()
  677. #endif
  678.